package com.logistica.metropolitana.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeUtils {
	
	public static final String DATE_PATTERN_DDMMYYYY = "dd/MM/yyyy";
	
	public static String convertJavaDateToStringDate(java.util.Date date) {
		SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
		return sdf.format(date);
	}
	
	public static Date convertStringToDate(String date, String pattern){
		if (date == null)
			return null;
		
		SimpleDateFormat sdf = new SimpleDateFormat(pattern);
		java.util.Date parsedDate = null;
		
		try {
			parsedDate = (Date) sdf.parse(date);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return parsedDate;
	}
}
